#!/bin/sh
#/home/firear/AndroidStudioProjects/AdTest/app/build/outputs/apk/gudebug/app-gudebug.apk

echo $#

if [ $# -lt 7 ];then
 echo  csjappid pkgname splash reward  umengkey umengchannel signkey appname icon
 exit 0
fi


rm -rf t
cp -a  r t

csjappid=$1
pkgname="$2"
Splash=$3

RewardVideo=$4

umengkey=$5
umengchannel=$6

signkey=$7

if [ $# -gt 7 ];then
	appname=${8}
fi
if [ $# -gt 8 ];then
	icon=${9}
fi

#umeng UMConfigure;->init
sed -i "s/5e6cf018570df3adbb0001d2/$umengkey/" t/smali_classes3/hzzy/AdUtils/AdConfig.smali
sed -i "s/rearif/$umengchannel/" t/smali_classes3/hzzy/AdUtils/AdConfig.smali
sed -i "s/com.yagogame.rzdh/$pkgname/" t/smali_classes3/hzzy/AdUtils/AdConfig.smali
#
#    invoke-static {p0}, Lhzzy/AdUtils/EntryApplication;->entry(Landroid/content/Context;)V
#    invoke-static {p0}, Lcom/yinghetestapp/EntryApplication;->initMyad(Landroid/content/Context;)V
#
#bytedance  TTAdConfig$Builder;->appI
#AdSlot$Builder;->setCodeId
#getIdentifier
if [ "$csjappid" != "" ];then
	sed -i "s/5068814/$csjappid/" t/smali_classes3/hzzy/AdUtils/AdConfig.smali
else
	echo appid is null
	exit 0
fi

if [ "$RewardVideo" != "" ];then
  sed -i "s/945200084/$RewardVideo/" t/smali_classes3/hzzy/AdUtils/AdConfig.smali
fi
if [ "$Splash" != "" ];then
  sed -i "s/887328327/$Splash/" t/smali_classes3/hzzy/AdUtils/AdConfig.smali
fi


#pkgname

#sed -i "s/renameManifestPackage: null/renameManifestPackage: $pkgname/" t/apktool.yml
#sed -i "s/authorities=\"com.huluxia.gametools\./authorities=\"$pkgname./" t/AndroidManifest.xml

if [ "$appname" != "" ];then
	sed -i "s/葫芦侠/$appname/" t/res/values/strings.xml
fi

if [ "$icon" != "" ];then
	for dst in t/res/drawable*/tool_app_icon.png;do
		cp $icon $dst
	done
fi

if [ "$res" != "" ];then
	cp $res t/assets/00001.png
fi

apktool b -f t/
signapkj.sh  t/dist/*.apk  ~/junk/$umengchannel.apk $signkey
echo ~/junk/$umengchannel.apk
#mv t/dist/*.apk ~/junk/$umengchannel.apk

